<?php
require_once("lib.php");

$user = &get_user();

$dbc = dbc();

$rjs = array();

$res = $dbc->query(sprintf('select * from uorder where user_id=%d order by id desc limit 5', $user['user_id']));
if($res) {
    while($row = $res->fetch_assoc()) {
        $row['js'] = json_decode($row['js'], true);
        
        $js = array();
        $js['order_info'] = $row['js']['order_info'];
        $js['total'] = $row['js']['total'];
        $js['items'] = $row['js']['items'];
        
        $rjs[] = array(
            'id'=>$row['id'],
            'dt'=>date("F j, Y, g:i a", $row['ts']),
            'order_info'=>$row['js']['order_info'],
            'total'=>$row['js']['total'],
            'items'=>$row['js']['items']
        );
    }
}

print json_encode($rjs);

